// components/topList/topList.js
import request from '../../utils/request'

Component({
    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
        topList:[],
    },

    /**
     * 组件的方法列表
     */
    methods: {
        
    },

    lifetimes:{
        async attached(){
            let index = 0;
            let tempArr = [];
            while(index < 5){
                const {data:topListData} = await request('/top/list',{idx:index++})

                const topListItem = {name:topListData.playlist.name,
                tracks:topListData.playlist.tracks.slice(0,3)
                };

                tempArr.push(topListItem);

                this.setData({
                    topList:tempArr
                })
            }
          
        }
    }

})
